package com.x.prompt;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.springframework.ai.chat.messages.Message;
import org.springframework.ai.chat.prompt.PromptTemplate;
import org.springframework.ai.chat.prompt.SystemPromptTemplate;
import org.springframework.stereotype.Component;

/**
 * @author xjk
 * @date 2025-07-01
 */
@Component
public class PromptCreator {


  /** 缓存已加载的prompt内容 */
  private final Map<String, String> promptCache = new ConcurrentHashMap<>();


  public Message createSystemMessage(String promptContent, Map<String,Object> variableMapping) {
    SystemPromptTemplate promptTemplate = new SystemPromptTemplate(promptContent);
    return promptTemplate.createMessage(variableMapping);
  }

  public Message createUserMessage(String promptContent, Map<String,Object> variableMapping) {
    PromptTemplate promptTemplate = new PromptTemplate(promptContent);
    return promptTemplate.createMessage(variableMapping);
  }

}
